<?php
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
$requst_uri = $_SERVER['REQUEST_URI'];
preg_match('/.*\/shop\/(.*)/i',$requst_uri,$matches);
if(count($matches) != 2)
{
	header('Location:http://www.zhejuan.com');
}
$subdomain = $matches[1];
$supplyInfo = zhejuan_get_supply_by_domain($subdomain);
if($supplyInfo)
{
	header('Location:../brand.php?id='.$supplyInfo['brand_id']);
}else{
	exit("Specify supply doesn't exists.");
}
function zhejuan_get_supply_by_domain($subdomain)
{

	global $db;
	$sql = "SELECT `s`.*,`b`.`brand_id` FROM ecs_suppliers AS `s`,ecs_brand AS `b` WHERE `s`.`suppliers_id` = `b`.`suppliers_id` AND `s`.`sitename` ='".mysql_real_escape_string($subdomain)."'";
	return $db->getRow($sql);
}
?>